#include "DynamicArray.h"
#include <iostream>
int main()
{

    DynamicArray a;                 // 无参构造     
    for (int i = 0; i < 10; i++)
        a.InsertTail(i+1);
    a.show();
    std::cout<<std::endl;

    DynamicArray b(a);              //拷贝构造
    b.show();
    std::cout<<std::endl;

    int num = 10;
    if(a.FindByElemrnt(num) == -1)
    std::cout<<"未找到该元素!\n";   //普通查找,返回下标
    else
    std::cout<<a.FindByElemrnt(num)<<std::endl;   
    std::cout<<std::endl;

    int index = 4;
    b.RemoveByIndex(index);     //按下标删除
    b.show();
    printf("下标为%d的元素已删除!\n",index);
    std::cout<<std::endl;

    int element = 10;
    b.RemoveByElement(element); //按元素删除
    b.show();
    printf("元素%d已删除!\n",element);
    std::cout<<std::endl;
    // b.RemoveByElement(10);
    // b.show();

    std::cout<<"排序前:"<<std::endl;     //排序
    DynamicArray c;
    c.InsertTail(5);
    c.InsertTail(3);
    c.InsertTail(4);
    c.InsertTail(1);
    c.InsertTail(2);
    c.show();
    std::cout<<"排序后:"<<std::endl;
    c.FastSort(0,4);
    c.show();
    std::cout<<std::endl;

    a.show();                               
    std::cout<<a.BinarySearch(10)<<std::endl;  //二分
  
    return 0;
}
